<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

    class Report_model extends MY_Model
    {
        public function __construct() 
        {
            parent::__construct();
            $this->tbl_name = 'reports';
        }
               
        function getBasicReportByCompany($company_id) 
        {
            $sql = "SELECT *
                    FROM reports
                    WHERE active = 1
                    AND report_types_id = 0
                    AND companies_id = $company_id
                    ORDER BY id DESC";    
            
            $query = $this->db->query($sql);

            $data = array();
            if ($query->num_rows() > 0)
            {
               foreach ($query->result_array() as $row)
               {
                    $data[] = $row;    
               }
               return $data;
            }
        }
        
        function getFinanceReportByCompany($company_id) 
        {
            $sql = "SELECT *
                    FROM reports
                    WHERE active = 1
                    AND report_types_id = 1
                    AND companies_id = $company_id
                    ORDER BY id DESC";    
            
            $query = $this->db->query($sql);

            $data = array();
            if ($query->num_rows() > 0)
            {
               foreach ($query->result_array() as $row)
               {
                    $data[] = $row;    
               }
               return $data;
            }
        }
    }
?>
